package com.ruoyi.web.controller.xinfeng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.daily.domain.XinfengDailyWork;
import com.ruoyi.daily.service.IXinfengDailyWorkService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日常工作Controller
 * 
 * @author gyy
 * @date 2025-04-19
 */
@RestController
@RequestMapping("/xinfeng/daily/work")
public class XinfengDailyWorkController extends BaseController
{
    @Autowired
    private IXinfengDailyWorkService xinfengDailyWorkService;

    /**
     * 查询日常工作列表
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:list')")
    @GetMapping("/list")
    public TableDataInfo list(XinfengDailyWork xinfengDailyWork)
    {
        startPage();
        List<XinfengDailyWork> list = xinfengDailyWorkService.selectXinfengDailyWorkList(xinfengDailyWork);
        return getDataTable(list);
    }

    /**
     * 导出日常工作列表
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:export')")
    @Log(title = "日常工作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XinfengDailyWork xinfengDailyWork)
    {
        List<XinfengDailyWork> list = xinfengDailyWorkService.selectXinfengDailyWorkList(xinfengDailyWork);
        ExcelUtil<XinfengDailyWork> util = new ExcelUtil<XinfengDailyWork>(XinfengDailyWork.class);
        util.exportExcel(response, list, "日常工作数据");
    }

    /**
     * 获取日常工作详细信息
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xinfengDailyWorkService.selectXinfengDailyWorkById(id));
    }

    /**
     * 新增日常工作
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:add')")
    @Log(title = "日常工作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XinfengDailyWork xinfengDailyWork)
    {
        return toAjax(xinfengDailyWorkService.insertXinfengDailyWork(xinfengDailyWork));
    }

    /**
     * 修改日常工作
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:edit')")
    @Log(title = "日常工作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XinfengDailyWork xinfengDailyWork)
    {
        return toAjax(xinfengDailyWorkService.updateXinfengDailyWork(xinfengDailyWork));
    }

    /**
     * 删除日常工作
     */
    @PreAuthorize("@ss.hasPermi('xinfeng:work:remove')")
    @Log(title = "日常工作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xinfengDailyWorkService.deleteXinfengDailyWorkByIds(ids));
    }
}
